package com.utils;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.alibaba.fastjson.JSONObject;
//表格返回json
public class TableUtils {
    
    //list转表格json
    public static JSONObject tableResult(List list) {
	Map<String, Object> map = new HashMap<String, Object>();
	map.put("code", 0);
	map.put("msg", "ok");
	map.put("count", list.size());
	map.put("data", list);
	JSONObject jsonObject = new JSONObject(map);
	return jsonObject;
    }

    //分页返回的json
    public static JSONObject tablePageResult(List list,Integer size) {
	Map<String, Object> map = new HashMap<String, Object>();
	map.put("code", 0);
	map.put("msg", "ok");
	map.put("count", size);
	map.put("data", list);
	JSONObject jsonObject = new JSONObject(map);
	return jsonObject;
    }

}
